﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SystemCenterSoa.DtoModel.SystemManager.ApplyGather;
using SystemCenterSoa.PoModel.SystemManager.ApplyGather;
using SystemCenterSoa.Service.SystemManager.ApplyGather;

namespace SystemCenterSoa.ApiProject.Area.SystemManager.ApplyGather
{
    public class FieldApplyController : SystemManagerBaseController
    {
        private FieldApplyService _fieldApplyService;

        public FieldApplyController(FieldApplyService fieldApplyService)
        {
            _fieldApplyService = fieldApplyService;
        }
        [HttpPost]
        public bool GetFieldApplyAdd(FieldApplyPo fieldApply)
        {
            return _fieldApplyService.GetFieldApplyAdd(fieldApply);
        }
        [HttpGet]
        public IActionResult GetFieldApplyList(int deId, string nian, string yue, int pageIndex, int pageSize)
        {
            try
            {
                var query = _fieldApplyService.GetFieldApplyList(deId, nian, yue, pageIndex, pageSize);
                var total = query.Count();
                var list = query.OrderBy(t => t.wq_id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                return Ok(new { list, total });
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public FieldApplyPo GetFieldApplyFan(int id)
        {
            return _fieldApplyService.GetFieldApplyFan(id);
        }
        [HttpPost]
        public bool GetFieldApplyUpdate(FieldApplyPo fieldApply)
        {
            return _fieldApplyService.GetFieldApplyUpdate(fieldApply);
        }
        [HttpPost]
        public bool GetFieldApplyDel(string ids)
        {
            return _fieldApplyService.GetFieldApplyDel(ids);
        }
    }
}
